package com.hopu.v1.service.admin.verify.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.v1.pojo.common.PageData;
import com.hopu.v1.pojo.question.Questions;
import com.hopu.v1.service.admin.verify.VerifyQuestionsService;
import com.hopu.v1.mapper.admin.verify.VerifyQuestionsMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
@Service
public class VerifyQuestionsServiceImpl extends ServiceImpl<VerifyQuestionsMapper, Questions>
    implements VerifyQuestionsService {

    @Resource
    private VerifyQuestionsMapper verifyQuestionsMapper;

    @Override
    public Map selectAll(Integer currentPage, Integer pageSize) {
        Page<Questions> questionsPage = verifyQuestionsMapper.selectPage(new Page<>(currentPage,pageSize), null);
        List<Questions> records = questionsPage.getRecords(); //获取当前页数据
        long total = questionsPage.getTotal();       //获取总记录数
        Map map = new HashMap();
        map.put("records",records);
        map.put("total",total);
        return map;
    }

    @Override
    public PageData<Questions> selectAll(Integer currentPage, Integer pageSize,String status) {
        List<Questions> subjects = verifyQuestionsMapper.selectAll((currentPage-1)*pageSize, pageSize,status);
        Integer total = verifyQuestionsMapper.selectAllCount();
        return new PageData<>(currentPage,pageSize,total,subjects);
    }
}




